/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package AdminManagerment.gui;

import AdminManagerment.chart.InterviewByInterChart;
import AdminManagerment.chart.InterviewBySchedulerChart;
import AdminManagerment.chart.TotalInterviewBarChart;
import AdminManagerment.chart.TotalInterviewPieChart;
import AdminManagerment.entities.Staff;
import AdminManagerment.jdbc.InterviewByInterviewer;
import AdminManagerment.jdbc.InterviewByScheduler;
import AdminManagerment.jdbc.Staffs;
import AdminManagerment.jdbc.TotalInterview;
import Application.MarvellFrame;
import DataServices.Validate;
import java.awt.Font;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Tngoc
 */
public class Administrative extends javax.swing.JFrame implements MarvellFrame {

    private TotalInterviewPieChart totalPie;
    private TotalInterviewBarChart totalBar;
    private TotalInterviewBarChart companyBar;
    private InterviewBySchedulerChart interviewBySche;
    private InterviewByInterChart interviewByInter;
    private Staffs staffList;
    private ArrayList<Staff> rowData;
    private DefaultTableModel model;
    private int rowSelected;
    private InterviewByInterviewer ibi;
    private InterviewByScheduler ibs;
    private Validate validate;

    private void userInit() {
        validate = new Validate();
        staffList = new Staffs();
        ibi = new InterviewByInterviewer();
        interviewByInter = new InterviewByInterChart(this, ibi.getData());
        ibs = new InterviewByScheduler();
        interviewBySche = new InterviewBySchedulerChart(this, ibs.getData());
        model = (DefaultTableModel) staffTable.getModel();
        areaOutput.setFont(new Font("", Font.ITALIC, 12));
        staffFilter(true, true, true, true);
        Calendar time = Calendar.getInstance();
        int year = time.get(Calendar.YEAR);
        int minYear = year - 5;
        for (int i = minYear; i < year + 1; i++) {
            comboYear.addItem(i);
            comboYear.setSelectedItem(i);
        }
        errorPw1.setVisible(false);
        errorPw2.setVisible(false);
        errorEmail.setVisible(false);
        errorUname.setVisible(false);
        pwAdminError.setVisible(false);
        addPanel.setVisible(false);
        error.setVisible(false);

        this.pack();
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
            /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
            Logger.getLogger(Administrative.class.getName()).log(Level.SEVERE, null, ex);
        }

        //</editor-fold>
    }

    private void staffFilter(boolean Scheduler, boolean Interviewer, boolean active, boolean disable) {
        rowData = staffList.getStaff();
        filterNothing();
        for (Staff s : rowData) {
            String r;
            if (s.getRole() == 2) {
                r = "Scheduler";
            } else if (s.getRole() == 3) {
                r = "Interviewer";
            } else {
                continue;
            }
            String act;

            if (s.isActive() == true) {
                act = "Active";
            } else {
                act = "Disable";
            }
            if (!Scheduler) {
                if ("Scheduler".equals(r)) {
                    continue;
                }
            }
            if (!Interviewer) {
                if ("Interviewer".equals(r)) {
                    continue;
                }
            }
            if (!active) {
                if ("Active".equals(act)) {
                    continue;
                }
            }
            if (!disable) {
                if ("Disable".equals(act)) {
                    continue;
                }
            }
            String gd;
            if (s.isGender()) {
                gd = "male";
            } else {
                gd = "female";
            }
            Object[] data = new Object[]{s.getName(), r, gd, s.getEmail(), s.getAddress(), act};
            model.addRow(data);
        }
    }

    private void setEditable(boolean flag) {
        txtUserName.setEditable(flag);
        txtEmail.setEditable(flag);
        txtAddress.setEditable(flag);
        comGender.setEnabled(flag);
        staffTable.setEnabled(!flag);
        btnSave.setEnabled(flag);
        btnCancelEdit.setEnabled(flag);
        btnRefresh.setEnabled(!flag);
        btnEditStaff.setEnabled(!flag);
    }

    private void filterNothing() {
        for (int i = model.getRowCount() - 1; i >= 0; i--) {
            model.removeRow(i);
        }
    }

    private void changeModelData() {
        staffFilter(menuViewSche.isSelected(), menuViewInter.isSelected(), menuViewActive.isSelected(), menuViewDisable.isSelected());
    }

    private void showStaffInfo(int row) {
        txtUserName.setText(model.getValueAt(row, 0).toString());
        txtActive.setText(model.getValueAt(row, 5).toString());
        txtRole.setText(model.getValueAt(row, 1).toString());
        txtEmail.setText(model.getValueAt(row, 3).toString());
        txtAddress.setText(model.getValueAt(row, 4).toString());
        comGender.setSelectedItem(model.getValueAt(row, 2));
    }

    /**
     * Creates new form Administrative
     */
    public Administrative() {
        initComponents();
        userInit();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        changePassFrame = new javax.swing.JFrame();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        adminPass1 = new javax.swing.JPasswordField();
        adminPass2 = new javax.swing.JPasswordField();
        btnSavePassword = new javax.swing.JButton();
        btnCancelPassword = new javax.swing.JButton();
        pwAdminError = new javax.swing.JLabel();
        pwPassword = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        staffTable = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        btnActive = new javax.swing.JButton();
        btnSave = new javax.swing.JButton();
        txtUserName = new javax.swing.JTextField();
        txtActive = new javax.swing.JTextField();
        btnRefresh = new javax.swing.JButton();
        txtRole = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        txtEmail = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        txtAddress = new javax.swing.JTextField();
        comGender = new javax.swing.JComboBox();
        jLabel15 = new javax.swing.JLabel();
        btnEditStaff = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        error = new javax.swing.JLabel();
        btnCancelEdit = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        areaOutput = new javax.swing.JTextArea();
        statisticPanel = new javax.swing.JPanel();
        comboMonth = new javax.swing.JComboBox();
        comboYear = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        btnPieChart = new javax.swing.JButton();
        btnBarChart = new javax.swing.JButton();
        addPanel = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        addUserName = new javax.swing.JTextField();
        pw1 = new javax.swing.JPasswordField();
        pw2 = new javax.swing.JPasswordField();
        role = new javax.swing.JComboBox();
        txtAddEmail = new javax.swing.JTextField();
        txtAddAddress = new javax.swing.JTextField();
        comAddGender = new javax.swing.JComboBox();
        errorUname = new javax.swing.JLabel();
        errorPw1 = new javax.swing.JLabel();
        errorPw2 = new javax.swing.JLabel();
        errorEmail = new javax.swing.JLabel();
        btnCancel = new javax.swing.JButton();
        btnAdd = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        menuAdd = new javax.swing.JMenu();
        menuAddSche = new javax.swing.JMenuItem();
        menuAddInter = new javax.swing.JMenuItem();
        menuView = new javax.swing.JMenu();
        menuViewSche = new javax.swing.JCheckBoxMenuItem();
        menuViewInter = new javax.swing.JCheckBoxMenuItem();
        menuViewActive = new javax.swing.JCheckBoxMenuItem();
        menuViewDisable = new javax.swing.JCheckBoxMenuItem();
        menuStatistic = new javax.swing.JMenu();
        menuStatisticInter = new javax.swing.JMenuItem();
        menuStatisticSche = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();
        menuConfig = new javax.swing.JMenu();
        menuConfigChangePass = new javax.swing.JMenuItem();

        jLabel11.setText("password");

        jLabel12.setText("retype");

        btnSavePassword.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/Button White Check.png"))); // NOI18N
        btnSavePassword.setText("save");
        btnSavePassword.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSavePasswordActionPerformed(evt);
            }
        });

        btnCancelPassword.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/Minus Red Button.png"))); // NOI18N
        btnCancelPassword.setText("cancel");
        btnCancelPassword.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelPasswordActionPerformed(evt);
            }
        });

        pwAdminError.setForeground(new java.awt.Color(255, 51, 0));
        pwAdminError.setText("retype password");

        javax.swing.GroupLayout changePassFrameLayout = new javax.swing.GroupLayout(changePassFrame.getContentPane());
        changePassFrame.getContentPane().setLayout(changePassFrameLayout);
        changePassFrameLayout.setHorizontalGroup(
            changePassFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(changePassFrameLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(changePassFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(changePassFrameLayout.createSequentialGroup()
                        .addGroup(changePassFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(changePassFrameLayout.createSequentialGroup()
                                .addComponent(jLabel11)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(adminPass1))
                            .addGroup(changePassFrameLayout.createSequentialGroup()
                                .addComponent(jLabel12)
                                .addGap(18, 18, 18)
                                .addGroup(changePassFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(pwAdminError)
                                    .addComponent(adminPass2, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, changePassFrameLayout.createSequentialGroup()
                        .addGap(0, 161, Short.MAX_VALUE)
                        .addComponent(btnSavePassword, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnCancelPassword)))
                .addContainerGap())
        );
        changePassFrameLayout.setVerticalGroup(
            changePassFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(changePassFrameLayout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(changePassFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(changePassFrameLayout.createSequentialGroup()
                        .addGroup(changePassFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel11)
                            .addComponent(adminPass1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(changePassFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel12)
                            .addComponent(adminPass2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pwAdminError)
                        .addGap(0, 70, Short.MAX_VALUE))
                    .addGroup(changePassFrameLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addGroup(changePassFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnCancelPassword)
                            .addComponent(btnSavePassword))))
                .addContainerGap())
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setResizable(false);

        pwPassword.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Company Staff", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 14), new java.awt.Color(0, 153, 204))); // NOI18N
        pwPassword.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                staffTableMouseClicked(evt);
            }
        });

        staffTable.setAutoCreateRowSorter(true);
        staffTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Name", "Function", "Gender", "Email", "Address", "Status"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        staffTable.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        staffTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        staffTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                staffTableMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(staffTable);

        jLabel1.setText("user name");

        jLabel2.setText("role");

        jLabel5.setText("active");

        btnActive.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/star-gold.png"))); // NOI18N
        btnActive.setText("Active");
        btnActive.setEnabled(false);
        btnActive.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnActiveActionPerformed(evt);
            }
        });

        btnSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/arrow-left-blue.png"))); // NOI18N
        btnSave.setText("save");
        btnSave.setEnabled(false);
        btnSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveActionPerformed(evt);
            }
        });

        txtUserName.setEditable(false);

        txtActive.setEditable(false);

        btnRefresh.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/Button White Load.png"))); // NOI18N
        btnRefresh.setText("refresh");
        btnRefresh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRefreshActionPerformed(evt);
            }
        });

        txtRole.setEditable(false);

        jLabel13.setText("email");

        txtEmail.setEditable(false);

        jLabel14.setText("address");

        txtAddress.setEditable(false);

        comGender.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "male", "female" }));
        comGender.setEnabled(false);

        jLabel15.setText("gender");

        btnEditStaff.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/arrow-right-blue.png"))); // NOI18N
        btnEditStaff.setText("edit");
        btnEditStaff.setEnabled(false);
        btnEditStaff.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditStaffActionPerformed(evt);
            }
        });

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/Import Document.png"))); // NOI18N
        jButton1.setText("logout");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        error.setForeground(new java.awt.Color(255, 0, 0));
        error.setText("error !");

        btnCancelEdit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/alert-square-red.png"))); // NOI18N
        btnCancelEdit.setText("cancel");
        btnCancelEdit.setEnabled(false);
        btnCancelEdit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelEditActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pwPasswordLayout = new javax.swing.GroupLayout(pwPassword);
        pwPassword.setLayout(pwPasswordLayout);
        pwPasswordLayout.setHorizontalGroup(
            pwPasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pwPasswordLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pwPasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addGroup(pwPasswordLayout.createSequentialGroup()
                        .addComponent(btnRefresh, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnActive, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnEditStaff, javax.swing.GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE)))
                .addGroup(pwPasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pwPasswordLayout.createSequentialGroup()
                        .addGap(151, 151, 151)
                        .addComponent(jButton1))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pwPasswordLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pwPasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pwPasswordLayout.createSequentialGroup()
                                .addGroup(pwPasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(pwPasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addGroup(pwPasswordLayout.createSequentialGroup()
                                            .addGroup(pwPasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel2)
                                                .addComponent(jLabel5))
                                            .addGap(21, 21, 21))
                                        .addComponent(jLabel1))
                                    .addComponent(jLabel13)
                                    .addComponent(jLabel14)
                                    .addComponent(jLabel15))
                                .addGap(16, 16, 16)
                                .addGroup(pwPasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(error)
                                    .addGroup(pwPasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(comGender, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(txtRole, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 123, Short.MAX_VALUE)
                                        .addComponent(txtUserName, javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(txtActive, javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(txtEmail, javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(txtAddress, javax.swing.GroupLayout.Alignment.TRAILING))))
                            .addGroup(pwPasswordLayout.createSequentialGroup()
                                .addComponent(btnSave)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnCancelEdit)))))
                .addContainerGap())
        );
        pwPasswordLayout.setVerticalGroup(
            pwPasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pwPasswordLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pwPasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pwPasswordLayout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                        .addGap(18, 18, 18))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pwPasswordLayout.createSequentialGroup()
                        .addGap(0, 16, Short.MAX_VALUE)
                        .addGroup(pwPasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(txtUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pwPasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(txtRole, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pwPasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtActive, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pwPasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel13))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pwPasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel14)
                            .addComponent(txtAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pwPasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(comGender, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel15))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(error)
                        .addGap(18, 18, 18)
                        .addGroup(pwPasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(btnCancelEdit)
                            .addComponent(btnSave))
                        .addGap(54, 54, 54)))
                .addGroup(pwPasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE, false)
                    .addComponent(btnRefresh, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnActive, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnEditStaff, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1))
                .addContainerGap())
        );

        areaOutput.setBackground(new java.awt.Color(153, 153, 153));
        areaOutput.setColumns(20);
        areaOutput.setForeground(new java.awt.Color(0, 0, 153));
        areaOutput.setRows(5);
        jScrollPane2.setViewportView(areaOutput);

        statisticPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Company Statistic ", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 14), new java.awt.Color(0, 153, 204))); // NOI18N

        comboMonth.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" }));

        jLabel6.setText("month");

        jLabel7.setText("year");

        btnPieChart.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/Chart Pie.png"))); // NOI18N
        btnPieChart.setText("Pie chart");
        btnPieChart.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPieChartActionPerformed(evt);
            }
        });

        btnBarChart.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/Chart Bar.png"))); // NOI18N
        btnBarChart.setText("bar chart");
        btnBarChart.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBarChartActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout statisticPanelLayout = new javax.swing.GroupLayout(statisticPanel);
        statisticPanel.setLayout(statisticPanelLayout);
        statisticPanelLayout.setHorizontalGroup(
            statisticPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statisticPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(statisticPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnBarChart, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnPieChart, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(statisticPanelLayout.createSequentialGroup()
                        .addGroup(statisticPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(jLabel7))
                        .addGap(14, 14, 14)
                        .addGroup(statisticPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(comboYear, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(comboMonth, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        statisticPanelLayout.setVerticalGroup(
            statisticPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, statisticPanelLayout.createSequentialGroup()
                .addContainerGap(20, Short.MAX_VALUE)
                .addGroup(statisticPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(comboMonth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(statisticPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(comboYear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnPieChart)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnBarChart)
                .addContainerGap())
        );

        jLabel3.setText("user name");

        jLabel4.setText("password");

        jLabel8.setText("retype");

        jLabel9.setText("role");

        jLabel16.setText("email");

        jLabel17.setText("address");

        jLabel18.setText("gender");

        role.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Scheduler", "Interviewer" }));
        role.setEnabled(false);

        comAddGender.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "male", "female" }));

        errorUname.setForeground(new java.awt.Color(255, 0, 0));
        errorUname.setText("invalid");

        errorPw1.setForeground(new java.awt.Color(255, 0, 0));
        errorPw1.setText("cannot empty");

        errorPw2.setForeground(new java.awt.Color(255, 51, 0));
        errorPw2.setText("retype");

        errorEmail.setForeground(new java.awt.Color(255, 0, 0));
        errorEmail.setText("cannot empty");

        btnCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/Minus Red Button.png"))); // NOI18N
        btnCancel.setText("cancel");
        btnCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelActionPerformed(evt);
            }
        });

        btnAdd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/User.png"))); // NOI18N
        btnAdd.setText("add");
        btnAdd.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                addNewClicked(evt);
            }
        });
        btnAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout addPanelLayout = new javax.swing.GroupLayout(addPanel);
        addPanel.setLayout(addPanelLayout);
        addPanelLayout.setHorizontalGroup(
            addPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(addPanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(addPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4)
                    .addComponent(jLabel8)
                    .addComponent(jLabel9)
                    .addComponent(jLabel16)
                    .addComponent(jLabel17)
                    .addComponent(jLabel18))
                .addGap(34, 34, 34)
                .addGroup(addPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(comAddGender, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(addPanelLayout.createSequentialGroup()
                        .addGroup(addPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(txtAddEmail, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtAddAddress, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(role, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(pw1, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(addUserName, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(pw2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(addPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(errorEmail)
                            .addComponent(errorUname)
                            .addComponent(errorPw1)
                            .addComponent(errorPw2)))
                    .addGroup(addPanelLayout.createSequentialGroup()
                        .addComponent(btnAdd)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnCancel)))
                .addContainerGap())
        );
        addPanelLayout.setVerticalGroup(
            addPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(addPanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(addPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(addUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(errorUname))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(addPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(pw1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(errorPw1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(addPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pw2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(errorPw2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(addPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(role, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(addPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(txtAddEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(errorEmail))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(addPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtAddAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel17))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(addPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(comAddGender, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel18))
                .addGap(18, 18, 18)
                .addGroup(addPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnAdd)
                    .addComponent(btnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(112, 112, 112))
        );

        menuAdd.setText("Add new");

        menuAddSche.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/user-blue.png"))); // NOI18N
        menuAddSche.setText("Scheduler");
        menuAddSche.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuAddScheActionPerformed(evt);
            }
        });
        menuAdd.add(menuAddSche);

        menuAddInter.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/user-red.png"))); // NOI18N
        menuAddInter.setText("Interviewer");
        menuAddInter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuAddInterActionPerformed(evt);
            }
        });
        menuAdd.add(menuAddInter);

        menuBar.add(menuAdd);

        menuView.setText("View");

        menuViewSche.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK));
        menuViewSche.setSelected(true);
        menuViewSche.setText("Scheduler");
        menuViewSche.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/user-blue.png"))); // NOI18N
        menuViewSche.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                ViewSchedulerAction(evt);
            }
        });
        menuView.add(menuViewSche);

        menuViewInter.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, java.awt.event.InputEvent.ALT_MASK));
        menuViewInter.setSelected(true);
        menuViewInter.setText("Interviewer");
        menuViewInter.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/user-red.png"))); // NOI18N
        menuViewInter.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                viewInterviewAction(evt);
            }
        });
        menuView.add(menuViewInter);

        menuViewActive.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.ALT_MASK));
        menuViewActive.setSelected(true);
        menuViewActive.setText("Active");
        menuViewActive.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/user-grey.png"))); // NOI18N
        menuViewActive.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuViewActiveActionPerformed(evt);
            }
        });
        menuView.add(menuViewActive);

        menuViewDisable.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D, java.awt.event.InputEvent.ALT_MASK));
        menuViewDisable.setSelected(true);
        menuViewDisable.setText("Disable");
        menuViewDisable.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/user-grey.png"))); // NOI18N
        menuViewDisable.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuViewDisableActionPerformed(evt);
            }
        });
        menuView.add(menuViewDisable);

        menuBar.add(menuView);

        menuStatistic.setText("Statistic");

        menuStatisticInter.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.ALT_MASK));
        menuStatisticInter.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/Chart Bar.png"))); // NOI18N
        menuStatisticInter.setText("Interviewer");
        menuStatisticInter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuStatisticInterActionPerformed(evt);
            }
        });
        menuStatistic.add(menuStatisticInter);

        menuStatisticSche.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK));
        menuStatisticSche.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/Chart Bar.png"))); // NOI18N
        menuStatisticSche.setText("Scheduler");
        menuStatisticSche.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuStatisticScheActionPerformed(evt);
            }
        });
        menuStatistic.add(menuStatisticSche);

        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.ALT_MASK));
        jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/Chart.png"))); // NOI18N
        jMenuItem1.setText("company Statistic");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        menuStatistic.add(jMenuItem1);

        menuBar.add(menuStatistic);

        menuConfig.setText("Admin");

        menuConfigChangePass.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/Briefcase.png"))); // NOI18N
        menuConfigChangePass.setText("change password");
        menuConfigChangePass.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuConfigChangePassActionPerformed(evt);
            }
        });
        menuConfig.add(menuConfigChangePass);

        menuBar.add(menuConfig);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pwPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 227, Short.MAX_VALUE)
                    .addComponent(statisticPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(addPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(5, 5, 5)
                                .addComponent(statisticPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane2))
                            .addComponent(pwPassword, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addComponent(addPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void ViewSchedulerAction(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_ViewSchedulerAction
        // TODO add your handling code here:
        changeModelData();
    }//GEN-LAST:event_ViewSchedulerAction

    private void viewInterviewAction(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_viewInterviewAction
        // TODO add your handling code here:
        changeModelData();
    }//GEN-LAST:event_viewInterviewAction

    private void menuStatisticScheActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuStatisticScheActionPerformed
        // TODO add your handling code here:
        ibs.refresh();
        interviewBySche.setDataset(ibs.getData());
        interviewBySche.showChart();
        areaOutput.append("show Scheduler bar chart !\n");
    }//GEN-LAST:event_menuStatisticScheActionPerformed

    private void btnBarChartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBarChartActionPerformed
        // TODO add your handling code here:
        int month = Integer.parseInt(comboMonth.getSelectedItem().toString());
        int year = Integer.parseInt(comboYear.getSelectedItem().toString());
        TotalInterview ti = new TotalInterview(month, year, 1);
        totalBar = new TotalInterviewBarChart(this, ti.getBarData());
        totalBar.showBarStatistic(month, year);
        areaOutput.append("show " + month + "/" + year + " bar chart !\n");
    }//GEN-LAST:event_btnBarChartActionPerformed

    private void btnPieChartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPieChartActionPerformed
        int month = Integer.parseInt(comboMonth.getSelectedItem().toString());
        int year = Integer.parseInt(comboYear.getSelectedItem().toString());
        TotalInterview ti = new TotalInterview(month, year, 0);
        totalPie = new TotalInterviewPieChart(this, ti.getPieData());
        totalPie.showPieStatistic(month, year);
        areaOutput.append("show " + month + "/" + year + " pie chart !\n");
    }//GEN-LAST:event_btnPieChartActionPerformed

    private void staffTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_staffTableMouseClicked
        rowSelected = staffTable.getSelectedRow();
        if (rowSelected != -1) {
            showStaffInfo(rowSelected);
            btnActive.setEnabled(true);
            btnEditStaff.setEnabled(true);
            if ("Active".equals(model.getValueAt(rowSelected, 5).toString())) {
                btnActive.setText("Disable");
                btnActive.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/star-grey.png")));
            } else {
                btnActive.setText("Active");
                btnActive.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/star-gold.png")));
            }
        }
    }//GEN-LAST:event_staffTableMouseClicked

    private void btnRefreshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRefreshActionPerformed
        changeModelData();
        areaOutput.append("refresh staff list !\n");
    }//GEN-LAST:event_btnRefreshActionPerformed

    private void menuViewActiveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuViewActiveActionPerformed
        // TODO add your handling code here:
        changeModelData();
    }//GEN-LAST:event_menuViewActiveActionPerformed

    private void menuViewDisableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuViewDisableActionPerformed
        // TODO add your handling code here:
        changeModelData();
    }//GEN-LAST:event_menuViewDisableActionPerformed

    private void btnActiveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnActiveActionPerformed
        // TODO add your handling code here:
        String stName = model.getValueAt(rowSelected, 0).toString();
        staffList.updateStaffStatus(stName);
        changeModelData();
        showStaffInfo(rowSelected);
        areaOutput.append(btnActive.getText() + " user " + stName + "\n");
    }//GEN-LAST:event_btnActiveActionPerformed

    private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed

        boolean gd;
        if ("male".equals(comGender.getSelectedItem().toString())) {
            gd = true;
        } else {
            gd = false;
        }
        if (checkUpdate()) {
            String name = validate.change(txtUserName.getText());
            String mail = validate.change(txtEmail.getText());
            String address = validate.change(txtAddress.getText());
            if (staffList.updateStaff(staffTable.getValueAt(rowSelected, 0).toString(), name, txtRole.getText().toString(), mail, address, gd)) {
                areaOutput.append("updated !\n");
                changeModelData();
                showStaffInfo(rowSelected);
                setEditable(false);
            }
            error.setVisible(false);
        } else {
            error.setVisible(true);
        }

    }//GEN-LAST:event_btnSaveActionPerformed

    private boolean checkUpdate() {
        if (validate.containsBlank(txtUserName.getText())) {
            areaOutput.append("user name cannot have space character !\n");
            return false;
        }
        if (!validate.isEmailValid(txtEmail.getText())) {
            areaOutput.append("email is not valid !\n");
            return false;
        }
        if(validate.isEmpty(txtUserName.getText())){
            areaOutput.append("user name is not valid !\n");
            return false;
        }
        validate.change(txtUserName.getText());
        validate.change(txtEmail.getText());
        return true;
    }

    private void menuAddScheActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuAddScheActionPerformed
        // TODO add your handling code here:
        addPanel.setVisible(true);
        addUserName.setText("");
        pw1.setText("");
        pw2.setText("");
        role.setSelectedItem("Scheduler");
        this.addPanel.setVisible(true);
        this.pack();
    }//GEN-LAST:event_menuAddScheActionPerformed

    private void menuAddInterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuAddInterActionPerformed
        // TODO add your handling code here:
        addUserName.setText("");
        pw1.setText("");
        pw2.setText("");
        role.setSelectedItem("Interviewer");
        this.addPanel.setVisible(true);
        this.pack();
    }//GEN-LAST:event_menuAddInterActionPerformed

    private void addNewClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_addNewClicked
        // TODO add your handling code here:
        boolean gd;
        if ("Male".equals(comAddGender.getSelectedItem().toString())) {
            gd = true;
        } else {
            gd = false;
        }
        if (checkEmpty()) {
            String name = validate.change(addUserName.getText());
            String mail = validate.change(txtAddEmail.getText());
            String address = validate.change(txtAddAddress.getText());
            System.out.println(name);
            if (staffList.insertStaff(name, new String(pw1.getPassword()), role.getSelectedItem().toString(), mail, address, gd)) {
                areaOutput.append("add staff " + addUserName.getText() + "\n");
                addPanel.setVisible(false);
                this.pack();
                changeModelData();
            }
        }
    }//GEN-LAST:event_addNewClicked

    private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
        // TODO add your handling code here:
        addPanel.setVisible(false);
        this.pack();
    }//GEN-LAST:event_btnCancelActionPerformed

    private void menuConfigChangePassActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuConfigChangePassActionPerformed
        // TODO add your handling code here:
        changePassFrame.pack();
        changePassFrame.setVisible(true);
    }//GEN-LAST:event_menuConfigChangePassActionPerformed

    private void btnSavePasswordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSavePasswordActionPerformed
        // TODO add your handling code here:
        if (String.valueOf(adminPass1.getPassword()).equals(String.valueOf(adminPass2.getPassword()))) {
            staffList.updateAdminPass(String.valueOf(adminPass1.getPassword()));
            changePassFrame.setVisible(false);
            areaOutput.append("update admin password");
            adminPass1.setText("");
            adminPass2.setText("");
        } else {
            pwAdminError.setVisible(true);
        }
    }//GEN-LAST:event_btnSavePasswordActionPerformed

    private void btnCancelPasswordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelPasswordActionPerformed
        // TODO add your handling code here:
        changePassFrame.setVisible(false);
    }//GEN-LAST:event_btnCancelPasswordActionPerformed

    private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddActionPerformed
    }//GEN-LAST:event_btnAddActionPerformed

    private void menuStatisticInterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuStatisticInterActionPerformed
        // TODO add your handling code here:
        ibi.refresh();
        interviewByInter.setDataset(ibi.getData());
        interviewByInter.showChart();
        areaOutput.append("show Interviewer bar chart !\n");
    }//GEN-LAST:event_menuStatisticInterActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:

        TotalInterview ti = new TotalInterview();
        companyBar = new TotalInterviewBarChart(this, ti.getCompanyData());

        companyBar.showCompanyStatistic();
        areaOutput.append("show company bar chart !\n");
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void btnEditStaffActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditStaffActionPerformed
        // TODO add your handling code here:
        setEditable(true);
        
    }//GEN-LAST:event_btnEditStaffActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        this.exitFrame();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void btnCancelEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelEditActionPerformed
        setEditable(false);
    }//GEN-LAST:event_btnCancelEditActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel addPanel;
    private javax.swing.JTextField addUserName;
    private javax.swing.JPasswordField adminPass1;
    private javax.swing.JPasswordField adminPass2;
    private javax.swing.JTextArea areaOutput;
    private javax.swing.JButton btnActive;
    private javax.swing.JButton btnAdd;
    private javax.swing.JButton btnBarChart;
    private javax.swing.JButton btnCancel;
    private javax.swing.JButton btnCancelEdit;
    private javax.swing.JButton btnCancelPassword;
    private javax.swing.JButton btnEditStaff;
    private javax.swing.JButton btnPieChart;
    private javax.swing.JButton btnRefresh;
    private javax.swing.JButton btnSave;
    private javax.swing.JButton btnSavePassword;
    private javax.swing.JFrame changePassFrame;
    private javax.swing.JComboBox comAddGender;
    private javax.swing.JComboBox comGender;
    private javax.swing.JComboBox comboMonth;
    private javax.swing.JComboBox comboYear;
    private javax.swing.JLabel error;
    private javax.swing.JLabel errorEmail;
    private javax.swing.JLabel errorPw1;
    private javax.swing.JLabel errorPw2;
    private javax.swing.JLabel errorUname;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JMenu menuAdd;
    private javax.swing.JMenuItem menuAddInter;
    private javax.swing.JMenuItem menuAddSche;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenu menuConfig;
    private javax.swing.JMenuItem menuConfigChangePass;
    private javax.swing.JMenu menuStatistic;
    private javax.swing.JMenuItem menuStatisticInter;
    private javax.swing.JMenuItem menuStatisticSche;
    private javax.swing.JMenu menuView;
    private javax.swing.JCheckBoxMenuItem menuViewActive;
    private javax.swing.JCheckBoxMenuItem menuViewDisable;
    private javax.swing.JCheckBoxMenuItem menuViewInter;
    private javax.swing.JCheckBoxMenuItem menuViewSche;
    private javax.swing.JPasswordField pw1;
    private javax.swing.JPasswordField pw2;
    private javax.swing.JLabel pwAdminError;
    private javax.swing.JPanel pwPassword;
    private javax.swing.JComboBox role;
    private javax.swing.JTable staffTable;
    private javax.swing.JPanel statisticPanel;
    private javax.swing.JTextField txtActive;
    private javax.swing.JTextField txtAddAddress;
    private javax.swing.JTextField txtAddEmail;
    private javax.swing.JTextField txtAddress;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtRole;
    private javax.swing.JTextField txtUserName;
    // End of variables declaration//GEN-END:variables

    private boolean checkEmpty() {
        if ("".equals(addUserName.getText()) || !staffList.checkName(addUserName.getText()) || validate.containsBlank(addUserName.getText())) {
            errorUname.setVisible(true);
            return false;
        } else {
            errorUname.setVisible(false);
        }
        if ("".equals(txtAddEmail.getText()) || !validate.isEmailValid(txtAddEmail.getText())) {
            errorEmail.setVisible(true);
            return false;
        } else {
            errorEmail.setVisible(false);
        }
        if ("".equals(String.copyValueOf(pw1.getPassword()))) {
            errorPw1.setVisible(true);
            return false;
        } else {
            errorPw1.setVisible(false);
        }
        if (!String.copyValueOf(pw1.getPassword()).equals(String.copyValueOf(pw2.getPassword()))) {
            errorPw2.setVisible(true);
            return false;
        } else {
            errorPw2.setVisible(false);
        }
        return true;
    }

    @Override
    public void startFrame(JFrame root) {
        this.setVisible(true);
        this.root = root;
        root.setVisible(false);
    }

    @Override
    public void exitFrame() {
        this.setVisible(false);
        root.setVisible(true);
    }
    private JFrame root;
}